package org.lmind.arena.ui;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;

public class Canvas {
	
	private BufferedImage image;
	
	private ArrayList<Spirit> spirits;
	
	public Canvas() {
		image = new BufferedImage(1024, 1024, BufferedImage.TYPE_INT_ARGB);
	}
	
	public void add(int index, Spirit spirit) {
		spirits.add(index, spirit);
	}
	
	public void add(Spirit spirit) {
		spirits.add(spirit);
	}
	
	public void remove(int index) {
		spirits.remove(index);
	}
	
	public void remove(Spirit spirit) {
		spirits.remove(spirit);
	}
	
	public int indexOf(Spirit spirit) {
		return spirits.indexOf(spirit);
	}
	
	public void render() {
		Graphics2D graphics = (Graphics2D)image.getGraphics();
		for (Spirit spirit : spirits) {
			spirit.render(graphics);
		}
	}
}
